<%--
  Created by IntelliJ IDEA.
  User: 风间琉璃
  Date: 2021/4/8
  Time: 20:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
  <head>
    <title>时光序</title>
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
  <script src="js/jquery-1.8.3.js"></script>
  <script src="js/bootstrap.js"></script>
  <div class="container">
    <div class="row">
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
      <div class="col-md-1">.col-md-1</div>
    </div>
  </div>
<%--  <c:if test="${empty infoList}">--%>
<%--    <script>--%>
<%--      location.href="InfoServlet?opr=list";--%>
<%--    </script>--%>
<%--  </c:if>--%>
  <div class=""></div>
  <table border="1">
    <tr>
      <td>收入支出信息编号</td>
      <td>用户id</td>
      <td>用户名</td>
      <td>支出类型id</td>
      <td>支出类型</td>
      <td>支付id</td>
      <td>支付方式</td>
      <td>支付金额</td>
      <td>备注</td>
      <td>创建时间</td>
      <td>操作</td>
    </tr>
    <c:forEach items="${infoList}" var="info" varStatus="status">
      <tr>
        <td>${info.iid}</td>
        <td>${info.uid}</td>
        <td>${info.uname}</td>
        <td>${info.sid}</td>
        <td>${info.selectedType}</td>
        <td>${info.pid}</td>
        <td>${info.method}</td>
        <td>${info.payMoney}</td>
        <td>${info.remark}</td>
        <td>${info.createTime}</td>
        <td><a href="javascript:void(0)" iid="${info.iid}" class="del">删除</a></td>
      </tr>
    </c:forEach>
  </table>
    <form id="Go" method="post" action="InfoServlet?opr=add">
      <table>
        <tr>
          <td>用户id</td>
          <td><input type="text" name="uid"></td>
        </tr>
        <tr>
          <td>支付方式</td>
          <td><input type="text" name="pid"></td>
        </tr>
        <tr>
          <td>支出类型</td>
          <td><input type="text" name="sid"></td>
        </tr>
        <tr>
          <td>消费金额</td>
          <td><input type="text" name="money"></td>
        </tr>
        <tr>
          <td>备注</td>
          <td><input type="text" name="remark"></td>
        </tr>
        <tr>
          <td>创建时间</td>
        </tr>
        <tr>
          <td><input type="submit" value="提交"></td>
        </tr>
      </table>
    </form>
  <script src="js/jquery-1.8.3.js"></script>
  <script>
    $(".del").click(function (){
      var iid = $(this).attr("iid");
      // console.log(iid);
      if (confirm("是否要删除该记录?")){
        $.post("InfoServlet?opr=del","iid="+iid,function (data) {
          alert(data);
          location.href="InfoServlet?opr=list";
        },"text");
      }
    })
  </script>

<%--    <script>--%>
<%--      $("#Go").submit(function () {--%>
<%--        $.ajax({--%>
<%--          url:"AddTallyServlet",--%>
<%--          type:"post",--%>
<%--          data:"{money:}"--%>
<%--        })--%>
<%--      })--%>
<%--    </script>--%>
  </body>
</html>
